#include <stdio.h>

int main() {
    int  i, j, n, sum;
    printf("Enter the number of rows and columns:\n");
    scanf("%d", &n);
    int a[n][n];
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++) {
            printf("Enter the element a[%d][%d]:\n", i, j);
            scanf("%d", *(a + i) + j);
        }
    //输出上三角元素和
    sum = 0;
    for (i = 0; i < n; i++)
        for (j = i; j < n; j++)
            sum = sum + *(*(a + i) + j);
    printf("%d", sum);

}